using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Lesson14work : MonoBehaviour
{
    // Start is called before the first frame update

    IEnumerator CreatCube(int num)
    {
        for (int i = 0; i < num; i++)
        {
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.position = new Vector3(Random.Range(-100, 101), Random.Range(-100, 101), Random.Range(-100, 101));
            if (i % 1000 == 0)
            {
                yield return null;
            }
        }
    }
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            StartCoroutine(CreatCube(100000));
            print(1);
        }
        //print(1);
    }
}
